package com.example;

import com.example.entity.Dep;
import com.example.entity.Emp;
import com.example.mapper.DepMapper;
import com.example.mapper.EmpMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SpringBootTest
class Java0325myBatisApplicationTests {

    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private DepMapper depMapper;

    @Test
    void testDepMapperer() {
        List<Emp> emps = empMapper.findEmpAll();
        for (Emp emp : emps){
            System.out.println(emp);
        }
    }

    @Test
    void testdept(){
        Dep dep = depMapper.selectDepById(1);
        System.out.println(dep);
    }

    @Test
    void testSelectEmp(){
        Emp emp = new Emp();
        emp.setName("张%");
        emp.setPosition("软件工程师");
        List<Emp> emps = empMapper.searchEmp(emp);
        for (Emp list : emps){
            System.out.println(list);
        }
    }

    @Test
    void testUpdataEmp(){
        Emp emp = new Emp();
        emp.setId(1);
        emp.setDepId(1);
        empMapper.updateEmp(emp);
        System.out.println("修改成功");
    };

    @Test
    void testselectEmpByIds(){
       List<Emp> emps = empMapper.selectEmpByIds(Arrays.asList(1,2,3));
       emps.forEach(System.out::println);

    }


}
